//
//  ViewController.m
//  HdMovie
//
//  Created by Classic on 12/13/12.
//  Copyright (c) 2012 Hoang tuan. All rights reserved.
//

#import "ViewController.h"
#import "ListMovieViewController.h"
#import "GetDataFromServer.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    _txtFldPass.delegate = self;
    _txtFldUserName.delegate = self;
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//-(UIColor *)colorFromHexString:(NSString *)hexString {
//    unsigned rgbValue = 0;
//    NSScanner *scanner = [NSScanner scannerWithString:hexString];
//    [scanner setScanLocation:1]; // bypass '#' character
//    [scanner scanHexInt:&rgbValue];
//    return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
//}
- (void)dealloc {
    self.txtFldUserName = nil;
    self.txtFldPass = nil;
    self.btnLogin =nil;
    [super dealloc];
}
- (IBAction)onClick:(id)sender {
    if (_txtFldUserName.text.length <= 0) {
        [self showAlert:@"Tên tài khoản không được để trống"];
    }else if (_txtFldPass.text.length <= 0){
        [self showAlert:@"Mật khẩu không được để trống"];
    }else{

        NSLog(@"%@",[GetDataFromServer getJsonObject:@"http://www.google.com/"]);
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        ListMovieViewController *listMovie = [storyboard instantiateViewControllerWithIdentifier:@"ListMovieViewController"];
        [listMovie setModalPresentationStyle:UIModalPresentationFullScreen];
        
        [self presentModalViewController:listMovie animated:YES];
        NSLog(LINK_LOGIN);
    }
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return NO;
}
-(void)showAlert:(NSString *)message
{
    UIAlertView *alMessErr = [[UIAlertView alloc] initWithTitle:@"Error" message:message delegate:nil cancelButtonTitle:@"Đồng Ý" otherButtonTitles:nil, nil];
    [alMessErr show];
}
- (void)viewDidUnload {
    [super viewDidUnload];
}
@end
